package com.tanhua.server.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.server.mapper.OptionsMapper;
import com.tanhua.server.pojo.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OptionsService {

    @Autowired
    private OptionsMapper optionsMapper;


    /**
     * 根据问题id查询对应的选项
     *
     * @param questionId
     * @return
     */
    public List<Options> queryOptionsById(String questionId) {
        //构建查询条件,根据问题id查询选项
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("question_id", questionId);
        //查询数据库获取对应的选项
        List<Options> optionsList = optionsMapper.selectList(queryWrapper);

        return optionsList;
    }


    /**
     * 根据问题id查询对应的选项
     *
     * @param optionId  选项id
     * @return
     */
    public Options queryById(String optionId) {
        //构建查询条件,根据问题id查询选项
        //查询数据库获取对应的选项
        Options options = optionsMapper.selectById(optionId);

        return options;
    }

}
